home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6987 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: cocoa.brown.edu!news
  2. From: Jaya Kumar Kanajan <jkk@lems.brown.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Newbie problem.
  5. Date: Wed, 21 Feb 1996 05:55:20 -0500
  6. Organization: LEMS Laboratory Brown University
  7. Message-ID: <312AFA18.604C@lems.brown.edu>
  8. NNTP-Posting-Host: lems34.lems.brown.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
  13.  
  14. I'm sorry for being a pest.
  15. But I am having the following problem and was hoping someone might have
  16. a quick solution.
  17.  
  18. I need to read in a .pgm file and output out a text file with numerical
  19. values. Example:
  20.  
  21. a 40x40 .pgm file stores greyscale values (0 to 255) as
  22. 0st row x0 x1 x2 x3 .......  x39
  23. 1nd row x40 x41 x42 ....... 
  24. .
  25. .
  26. .
  27. 39th row
  28.  
  29.  
  30. I would need to read this data in and then
  31. output accordingly to a text file giving
  32. //(xvalue) (yvalue) (colorvalue)
  33. //---------------------------------
  34.    0        0         111
  35.    1        0         203
  36.    .
  37.    .
  38.    
  39.  
  40. where each value needs to be spaced one character apart
  41.  
  42.  
  43.  
  44. I am using Solaris 2.5 and I would really appreciate any help.
  45.  
  46. Sincerely thankful for any time you spend on this.
  47.  
  48. Thanks,
  49. -jk
  50.  
  51.  
  52.  
  53. PS: I've been using
  54.  
  55. #input <iostream.h>
  56. #input <fstream.h>
  57.  
  58. then I was trying some cin << something
  59. and cout << something after loading the data into an array
  60. but I kept getting errors
  61.